#!/bin/sh -efu
### This file is covered by the GNU General Public License,
### which should be included with libshell as the file LICENSE.
### All copyright information are listed in the COPYING.

if [ -z "${__included_shell_string-}" ]; then
__included_shell_string=1

### Creates a mask of equal length string.
### Usage: fill_mask var str [full-length]
fill_mask()
{
__fill_mask()
{
	local m=
	while :; do
		case $((${#1} - ${#m})) in
			0) break ;;
			1) m="$m?" ;;
			2) m="$m??" ;;
			3) m="$m???" ;;
			4) m="$m????" ;;
			5) m="$m?????" ;;
			6) m="$m??????" ;;
			7) m="$m???????" ;;
			8) m="$m????????" ;;
			9) m="$m?????????" ;;
			*) m="$m??????????" ;;
		esac
	done
	__fill_masko="${m#$2}"
}
	local __fill_masko
	__fill_mask "$2" "${3:-?}"
	unset -f __fill_mask
	eval "$1=\$__fill_masko"
}

fi #__included_shell_string
